package com.wlhse.controller;

import com.wlhse.entity.ProblemDescriptionPojo;
import com.wlhse.service.ProblemDescriptionService;
import com.wlhse.util.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("ProblemDescriptionController")
@RequestMapping("/api/v3")
//问题描述
public class ProblemDescriptionController {

    @Resource
    private ProblemDescriptionService problemDescriptionService;

    @RequestMapping(value = "/problemdescriptions", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public String addProblemDescription(@RequestBody(required = false) ProblemDescriptionPojo planDescriptionPojo) {
            return problemDescriptionService.addProblemDescription(planDescriptionPojo);
    }

    @RequestMapping(value = "/problemdescriptions/{id}", method = RequestMethod.DELETE, produces = "application/json; charset=utf-8")
    public String deleteProblemDescription(@PathVariable int id) {
        return problemDescriptionService.deleteProblemDescription(id);
    }

    @RequestMapping(value = "/problemdescriptions/{id}", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
    public String updateProblemDescription(@PathVariable("id") int id, @RequestBody(required = false) ProblemDescriptionPojo planDescriptionPojo) {
        planDescriptionPojo.setId(id);
        return problemDescriptionService.updateProblemDescription(planDescriptionPojo);
    }

    @RequestMapping(value = "/problemdescriptions/{id}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public R queryProblemDescriptionsById(@PathVariable int id) {
        return problemDescriptionService.queryProblemDescriptionsById(id);
    }

    // 分页查
    @RequestMapping(value = "/problemdescriptions", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String queryProblemDescriptions(@ModelAttribute ProblemDescriptionPojo planDescriptionPojo) {
        return problemDescriptionService.queryProblemDescriptions(planDescriptionPojo);
    }

    @RequestMapping(value = "/problemdescriptions/description", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String queryProblemDescriptionsByDescription(@ModelAttribute ProblemDescriptionPojo problemDescriptionPojo) {
        return problemDescriptionService.queryProblemDescriptionsByDescription(problemDescriptionPojo);
    }
}
